﻿#include <stdio.h>
#include <string>
#include <iostream>


using namespace std;
//struct str {
//	int len;
//	char s[0];
//};

struct foo {
	struct str* a;
};
class A {
public:
	A() { ++_scount; }
	A(const A& t) { ++_scount; }
	~A() { --_scount; }
	static int GetACount() { return _scount; }
private:
	static int _scount;
};

int A::_scount = 0;

void TestA()
{
	cout << A::GetACount() << endl;   // 1

	A a1, a2;
	A a3(a1);

	cout << A::GetACount() << endl;   // 4
}
//int main(int argc, char** argv) {
//	
//	char s[5] = { 'a', 'b', 'c' };
//	//printf("%zu %zu\n", strlen(s), sizeof(s));
//	TestA();
//	 
//	return 0;
//}

// 继承中的隐藏
//class Base {
//public:
//	void func() {
//		cout << "无参" << endl;
//	}
//	void func(int) {
//		cout << "int" << endl;
//
//	}
//};
//
//class Derived : public Base {
//public:
//	//using Base::func; // 这个就可以解除隐藏
//	void func(double) {
//		cout << "double" << endl;
//	}
//};
//
//int main() {
//	Derived d;
//	//d.func();      // ❌ 错误：Base::func() 被隐藏
//	d.func(10);    // ❌ 错误：Base::func(int) 被隐藏
//	d.func(1.0);   // ✔ 正确：调用 Derived::func(double)
//	return 0;
//}


#include <iostream>
using namespace std;

class Base {
public:
	int x;

	Base() : x(0) {
		cout << "Base 默认构造\n";
	}

	Base(const Base& b) : x(b.x) {
		cout << "Base 拷贝构造\n";
	}
};

class Derived : public Base {
public:
	int y;

	Derived() : y(0) {
		cout << "Derived 默认构造\n";
	}

	// ⚠ 子类没有写拷贝构造！
	// C++ 会自动生成
};

int main() {
	cout << "== 构造 d1 ==\n";
	Derived d1;
	d1.x = 10;
	d1.y = 20;

	cout << "\n== 拷贝构造 d2(d1) ==\n";
	Derived d2 = d1;  // 拷贝构造

	cout << "\n== 打印 d2 值 ==\n";
	cout << "d2.x = " << d2.x << endl;
	cout << "d2.y = " << d2.y << endl;

	return 0;
}

